const debounce = function (fn,wait){
    let time = null;
    return function () {
        const self = this;
        const prms = arguments;
        if (time) {
            clearTimeout(time);
            time = null;
            return;
        }
        time = setTimeout(() => {
            fn.apply(self,prms);
        }, wait);
    }
}

const throttle = function (fn,wait){
    let pre = Date.now(); 
    return function () {
        const self = this;
        const prms = arguments;
        let now = Date.now();
        if (now - pre > wait) {
            return fn.apply(context, args)
        }
    }
}

const deepCopy = function (obj) {

    if ( !obj || object[key] !== "object") {
        return obj;
    }
    const newObj = Array.isArray(boj) ? [] : {};
    for (const key in obj) {
        if (obj.hasOwnProperty(key)) {
            newObj[key] =  typeof object[key] === "object" ? deepCopy(obj[key]) :  obj[key];
            
        }
    }
    return newObj;
}

Function.prototype.myBind = function(context,...res1){
// 判断调用对象是否为函数
    if (typeof this !== "function") {
        throw new TypeError("Error");
    }
    const fun = this;
    return function (...res2) {
        return fun.apply(context,res1.concat(res2))
    }


}